package MainPage;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * checkUpcomingEvent.java
 *
 * Created on 26 Oktober 2010, 8:41:07 PM
 */

import java.awt.Cursor;
import java.awt.Dimension;
import java.util.GregorianCalendar;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
/**
 *
 * @author EK
 */
public class checkUpcomingEvent extends javax.swing.JFrame {
    int realYear, realMonth, realDay, currentYear, currentMonth;
    String fday1,fday2,fday3,fday4,fday5,fday6,fday7;


    /** Creates new form checkUpcomingEvent */
    public checkUpcomingEvent() {
        initComponents();
        init();
        getTable();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);
        setSize(1225,700);
        setLocationRelativeTo(null);
    }



    //DATEBASE UPDATE PART
    private void updateRow(String edit)
    {
        try
        {
            userMainPage.stmt = userMainPage.con.createStatement();
            userMainPage.stmt.executeUpdate(edit);
        }
        catch (SQLException ex)
        {
            Logger.getLogger(checkUpcomingEvent.class.getName()).log(Level.SEVERE, null, ex);
        }

    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        Table2 = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        Table1 = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        Table5 = new javax.swing.JTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        Table3 = new javax.swing.JTable();
        jScrollPane6 = new javax.swing.JScrollPane();
        Table6 = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        Table7 = new javax.swing.JTable();
        jScrollPane7 = new javax.swing.JScrollPane();
        Table4 = new javax.swing.JTable();
        day1 = new javax.swing.JLabel();
        day2 = new javax.swing.JLabel();
        day3 = new javax.swing.JLabel();
        day4 = new javax.swing.JLabel();
        day5 = new javax.swing.JLabel();
        day6 = new javax.swing.JLabel();
        day7 = new javax.swing.JLabel();
        listAllBtn = new javax.swing.JButton();
        backButton = new javax.swing.JButton();
        background = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("UP-COMING EVENT");
        setMinimumSize(new java.awt.Dimension(700, 500));

        Table2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Time", "Type", "Event", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Table2.setToolTipText("Press Column Header for Sorting");
        Table2.setFillsViewportHeight(true);
        Table2.setPreferredSize(new java.awt.Dimension(250, 125));
        jScrollPane1.setViewportView(Table2);

        jScrollPane1.setBounds(20, 260, 380, 160);
        jLayeredPane1.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Table1.setAutoCreateRowSorter(true);
        Table1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Time", "Type", "Event", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Table1.setToolTipText("Press Column Header for Sorting");
        for (int i=0; i<4; i++) {
            TableColumn column = Table1.getColumnModel().getColumn(i);
            if (i==0) column.setPreferredWidth(30);
            if (i==1) column.setPreferredWidth(50);
            if (i==2) column.setPreferredWidth(70);
            if (i==3) column.setPreferredWidth(100);
        }
        Table1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Table1.setFillsViewportHeight(true);
        Table1.setInheritsPopupMenu(true);
        Table1.setPreferredSize(new java.awt.Dimension(250, 125));
        Table1.setSelectionBackground(new java.awt.Color(255, 153, 0));
        jScrollPane2.setViewportView(Table1);

        jScrollPane2.setBounds(420, 50, 380, 160);
        jLayeredPane1.add(jScrollPane2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Table5.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Time", "Type", "Event", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Table5.setToolTipText("Press Column Header for Sorting");
        Table5.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Table5.setFillsViewportHeight(true);
        Table5.setPreferredSize(new java.awt.Dimension(250, 125));
        jScrollPane4.setViewportView(Table5);

        jScrollPane4.setBounds(20, 490, 380, 160);
        jLayeredPane1.add(jScrollPane4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Table3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Time", "Type", "Event", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Table3.setToolTipText("Press Column Header for Sorting");
        Table3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Table3.setFillsViewportHeight(true);
        Table3.setPreferredSize(new java.awt.Dimension(250, 125));
        jScrollPane5.setViewportView(Table3);

        jScrollPane5.setBounds(420, 260, 380, 160);
        jLayeredPane1.add(jScrollPane5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Table6.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Time", "Type", "Event", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Table6.setToolTipText("Press Column Header for Sorting");
        Table6.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Table6.setFillsViewportHeight(true);
        Table6.setPreferredSize(new java.awt.Dimension(250, 125));
        jScrollPane6.setViewportView(Table6);

        jScrollPane6.setBounds(420, 490, 380, 160);
        jLayeredPane1.add(jScrollPane6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Table7.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Time", "Type", "Event", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Table7.setToolTipText("Press Column Header for Sorting");
        Table7.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Table7.setFillsViewportHeight(true);
        Table7.setPreferredSize(new java.awt.Dimension(250, 125));
        jScrollPane3.setViewportView(Table7);

        jScrollPane3.setBounds(820, 490, 380, 160);
        jLayeredPane1.add(jScrollPane3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Table4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Time", "Type", "Event", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Table4.setToolTipText("Press Column Header for Sorting");
        Table4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Table4.setFillsViewportHeight(true);
        Table4.setPreferredSize(new java.awt.Dimension(250, 125));
        jScrollPane7.setViewportView(Table4);

        jScrollPane7.setBounds(820, 260, 380, 160);
        jLayeredPane1.add(jScrollPane7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        day1.setFont(new java.awt.Font("Arial Black", 1, 18));
        day1.setForeground(new java.awt.Color(204, 0, 0));
        day1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        day1.setBounds(490, 20, 240, 20);
        jLayeredPane1.add(day1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        day2.setFont(new java.awt.Font("Arial Black", 1, 16));
        day2.setForeground(new java.awt.Color(204, 0, 0));
        day2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        day2.setBounds(110, 230, 200, 20);
        jLayeredPane1.add(day2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        day3.setFont(new java.awt.Font("Arial Black", 1, 16));
        day3.setForeground(new java.awt.Color(204, 0, 0));
        day3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        day3.setBounds(500, 230, 210, 20);
        jLayeredPane1.add(day3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        day4.setFont(new java.awt.Font("Arial Black", 1, 16));
        day4.setForeground(new java.awt.Color(204, 0, 0));
        day4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        day4.setBounds(900, 230, 220, 20);
        jLayeredPane1.add(day4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        day5.setFont(new java.awt.Font("Arial Black", 1, 16));
        day5.setForeground(new java.awt.Color(204, 0, 0));
        day5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        day5.setBounds(100, 460, 220, 20);
        jLayeredPane1.add(day5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        day6.setFont(new java.awt.Font("Arial Black", 1, 16));
        day6.setForeground(new java.awt.Color(204, 0, 0));
        day6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        day6.setBounds(500, 460, 220, 20);
        jLayeredPane1.add(day6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        day7.setFont(new java.awt.Font("Arial Black", 1, 16));
        day7.setForeground(new java.awt.Color(204, 0, 0));
        day7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        day7.setBounds(900, 460, 220, 20);
        jLayeredPane1.add(day7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        listAllBtn.setText("List All Event");
        listAllBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listAllBtnActionPerformed(evt);
            }
        });
        listAllBtn.setBounds(850, 190, 140, 23);
        listAllBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        jLayeredPane1.add(listAllBtn, javax.swing.JLayeredPane.DEFAULT_LAYER);

        backButton.setText("Back to Main Page");
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });
        backButton.setBounds(1010, 190, 170, 23);
        backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        jLayeredPane1.add(backButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        background.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/panel2.jpg"))); // NOI18N
        background.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        background.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        background.setBounds(0, 0, 1230, 740);
        jLayeredPane1.add(background, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1220, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
    	firstPage.playAudio2(getClass().getResource("/resource/buttonHit.wav").getFile());
    	performFirstPage();
    }                                          

    private void listAllBtnActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    	firstPage.playAudio2(getClass().getResource("/resource/buttonHit.wav").getFile());
    	performListPage();
    }

    void performFirstPage()
	{
		firstPage first_page=new firstPage()
		{
			public String getParameter(String name)
			{
		           if (name.equalsIgnoreCase("msg"))
		           {
		              return "Local Frame";
		           }
		           return null;
		    }
		};
		this.dispose();
		first_page.setSize(userMainPage.screensize.width, userMainPage.screensize.height);
		first_page.setVisible(true);
		
	}
    
    void performListPage()
	{
		listAllEvent list_page=new listAllEvent()
		{
			public String getParameter(String name)
			{
		           if (name.equalsIgnoreCase("msg"))
		           {
		              return "Local Frame";
		           }
		           return null;
		    }
		};
		this.dispose();
		list_page.setVisible(true);
		
	}
    
    public void init()
    {
        String[] months = {"JANUARY", "FEBUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"};
        String[] MON= {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
        GregorianCalendar cal = new GregorianCalendar(); //Create calendar
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        currentMonth = realMonth; //Match month and year
        currentYear = realYear;

        day1.setText(realDay+ " " + months[realMonth]+ " " +realYear);
        fday1 = realDay+ "-" + MON[realMonth]+ "-" +realYear;
        cal.clear(GregorianCalendar.HOUR_OF_DAY); // so doesn't override
        cal.set(GregorianCalendar.HOUR, 24);
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        day2.setText(realDay+ " " + months[realMonth]+ " " +realYear);
        fday2 = realDay+ "-" + MON[realMonth]+ "-" +realYear;
        cal.clear(GregorianCalendar.HOUR_OF_DAY); // so doesn't override
        cal.set(GregorianCalendar.HOUR, 24);
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        day3.setText(realDay+ " " + months[realMonth]+ " " +realYear);
        fday3 = realDay+ "-" + MON[realMonth]+ "-" +realYear;
         cal.clear(GregorianCalendar.HOUR_OF_DAY); // so doesn't override
        cal.set(GregorianCalendar.HOUR, 24);
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        day4.setText(realDay+ " " + months[realMonth]+ " " +realYear);
        fday4 = realDay+ "-" + MON[realMonth]+ "-" +realYear;
         cal.clear(GregorianCalendar.HOUR_OF_DAY); // so doesn't override
        cal.set(GregorianCalendar.HOUR, 24);
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        day5.setText(realDay+ " " + months[realMonth]+ " " +realYear);
        fday5 = realDay+ "-" + MON[realMonth]+ "-" +realYear;
         cal.clear(GregorianCalendar.HOUR_OF_DAY); // so doesn't override
        cal.set(GregorianCalendar.HOUR, 24);
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        day6.setText(realDay+ " " + months[realMonth]+ " " +realYear);
        fday6 = realDay+ "-" + MON[realMonth]+ "-" +realYear;
         cal.clear(GregorianCalendar.HOUR_OF_DAY); // so doesn't override
        cal.set(GregorianCalendar.HOUR, 24);
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        day7.setText(realDay+ " " + months[realMonth]+ " " +realYear);
        fday7 = realDay+ "-" + MON[realMonth]+ "-" +realYear;
         cal.clear(GregorianCalendar.HOUR_OF_DAY); // so doesn't override
         cal.set(GregorianCalendar.HOUR, -24*6);
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
        realYear = cal.get(GregorianCalendar.YEAR); //Get year
        System.out.println("RESET : " + realDay+ " " + months[realMonth]+ " " +realYear);
        currentMonth = realMonth; //Match month and year
        currentYear = realYear;

        
    }


    //int countRow = 0;
    //int countColumn = 0;
    //int countRow2 = 0;
    //int countColumn2 = 0;
    //int countRowControl = 0;
    //int countColumnControl = 0;
    NewTableModel jTable1 = new NewTableModel();
    NewTableModel jTable2 = new NewTableModel();
    NewTableModel jTable3 = new NewTableModel();
    NewTableModel jTable4 = new NewTableModel();
    NewTableModel jTable5 = new NewTableModel();
    NewTableModel jTable6 = new NewTableModel();
    NewTableModel jTable7 = new NewTableModel();
    private DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();

    class CenterRenderer extends DefaultTableCellRenderer
    {
	public CenterRenderer()
	{
		setHorizontalAlignment( CENTER );
	}
    }

    public void getTable()
    {
        CenterRenderer centerRenderer = new CenterRenderer();
        int countRow = 0;
        int countColumn = 0;
        int countRowControl = 0;
        int countColumnControl = 0;

        
        
        try {
           
            

            //------------------------------------------------------------------------------------------------------------------
            ResultSet rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday1+"' AND USER_CODE="+userMainPage.userCode+" ORDER BY EVENT_TIME");

            
            //creating 2d arrays of appropriate size according to database
            while (rset.next()){
                countRow++;
            }
            
            ResultSetMetaData metadata = rset.getMetaData();

            jTable1.setDataSize(countRow, 4);
            jTable1.setColumnNameSize();
            //end

            //adding column names to table model
            DatabaseMetaData meta = userMainPage.con.getMetaData();

            ResultSet rset2 = meta.getColumns(null, null, "EVENT", null);

            jTable1.setColumnName(0, "Time");
            jTable1.setColumnName(1, "Type");
            jTable1.setColumnName(2, "Event");
            jTable1.setColumnName(3, "Description");
            // end

            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday1+"' AND USER_CODE="+userMainPage.userCode+" ORDER BY EVENT_TIME");
            while(rset.next()){
                jTable1.addString(countRowControl, countColumnControl, rset.getString("EVENT_TIME"));
                countColumnControl++;
                jTable1.addString(countRowControl, countColumnControl, rset.getString("EVENT_TYPE"));
                countColumnControl++;
                jTable1.addString(countRowControl, countColumnControl, rset.getString("EVENT_TITLE"));
                countColumnControl++;
                jTable1.addString(countRowControl, countColumnControl, rset.getString("EVENT_DES"));
                countColumnControl++;
                
                countColumnControl = 0;
                countRowControl++;
            }
            //------------------------------------------------------------------------------------------------------------------
           
            countRow = 0;
            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday2+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");

            while (rset.next()){
                countRow++;
            }

            ResultSetMetaData metadata2 = rset.getMetaData();
            //countColumn2 = metadata.getColumnCount();

            jTable2.setDataSize(countRow, 4);
            jTable2.setColumnNameSize();
            //end

            DatabaseMetaData meta2 = userMainPage.con.getMetaData();

            rset = meta2.getColumns(null, null, "EVENT", null);

            // end

            jTable2.setColumnName(0, "Time");
            jTable2.setColumnName(1, "Type");
            jTable2.setColumnName(2, "Event");
            jTable2.setColumnName(3, "Description");

            countRowControl = 0;
            countColumnControl = 0;

            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday2+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");
            while(rset.next()){
                jTable2.addString(countRowControl, countColumnControl, rset.getString("EVENT_TIME"));
                countColumnControl++;
                jTable2.addString(countRowControl, countColumnControl, rset.getString("EVENT_TYPE"));
                countColumnControl++;
                jTable2.addString(countRowControl, countColumnControl, rset.getString("EVENT_TITLE"));
                countColumnControl++;
                jTable2.addString(countRowControl, countColumnControl, rset.getString("EVENT_DES"));
                countColumnControl++;

                countColumnControl = 0;
                countRowControl++;
            }

            //------------------------------------------------------------------------------------------------------------------

            countRow = 0;
            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday3+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");

            while (rset.next()){
                countRow++;
            }

            ResultSetMetaData metadata3 = rset.getMetaData();
            //countColumn2 = metadata.getColumnCount();

            jTable3.setDataSize(countRow, 4);
            jTable3.setColumnNameSize();
            //end

            DatabaseMetaData meta3 = userMainPage.con.getMetaData();

            rset = meta3.getColumns(null, null, "EVENT", null);

            // end

            jTable3.setColumnName(0, "Time");
            jTable3.setColumnName(1, "Type");
            jTable3.setColumnName(2, "Event");
            jTable3.setColumnName(3, "Description");

            countRowControl = 0;
            countColumnControl = 0;

            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday3+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");
            while(rset.next()){
                jTable3.addString(countRowControl, countColumnControl, rset.getString("EVENT_TIME"));
                countColumnControl++;
                jTable3.addString(countRowControl, countColumnControl, rset.getString("EVENT_TYPE"));
                countColumnControl++;
                jTable3.addString(countRowControl, countColumnControl, rset.getString("EVENT_TITLE"));
                countColumnControl++;
                jTable3.addString(countRowControl, countColumnControl, rset.getString("EVENT_DES"));
                countColumnControl++;

                countColumnControl = 0;
                countRowControl++;
            }

            //------------------------------------------------------------------------------------------------------------------

            countRow = 0;
            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday4+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");

            while (rset.next()){
                countRow++;
            }

            ResultSetMetaData metadata4 = rset.getMetaData();
            //countColumn2 = metadata.getColumnCount();

            jTable4.setDataSize(countRow, 4);
            jTable4.setColumnNameSize();
            //end

            DatabaseMetaData meta4 = userMainPage.con.getMetaData();

            rset = meta4.getColumns(null, null, "EVENT", null);

            // end

            jTable4.setColumnName(0, "Time");
            jTable4.setColumnName(1, "Type");
            jTable4.setColumnName(2, "Event");
            jTable4.setColumnName(3, "Description");

            countRowControl = 0;
            countColumnControl = 0;

            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday4+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");
            while(rset.next()){
                jTable4.addString(countRowControl, countColumnControl, rset.getString("EVENT_TIME"));
                countColumnControl++;
                jTable4.addString(countRowControl, countColumnControl, rset.getString("EVENT_TYPE"));
                countColumnControl++;
                jTable4.addString(countRowControl, countColumnControl, rset.getString("EVENT_TITLE"));
                countColumnControl++;
                jTable4.addString(countRowControl, countColumnControl, rset.getString("EVENT_DES"));
                countColumnControl++;

                countColumnControl = 0;
                countRowControl++;
            }

            //------------------------------------------------------------------------------------------------------------------

            countRow = 0;
            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday5+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");

            while (rset.next()){
                countRow++;
            }

            ResultSetMetaData metadata5 = rset.getMetaData();
            //countColumn2 = metadata.getColumnCount();

            jTable5.setDataSize(countRow, 4);
            jTable5.setColumnNameSize();
            //end

            DatabaseMetaData meta5 = userMainPage.con.getMetaData();

            rset = meta5.getColumns(null, null, "EVENT", null);

            // end

            jTable5.setColumnName(0, "Time");
            jTable5.setColumnName(1, "Type");
            jTable5.setColumnName(2, "Event");
            jTable5.setColumnName(3, "Description");

            countRowControl = 0;
            countColumnControl = 0;

            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday5+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");
            while(rset.next()){
                jTable5.addString(countRowControl, countColumnControl, rset.getString("EVENT_TIME"));
                countColumnControl++;
                jTable5.addString(countRowControl, countColumnControl, rset.getString("EVENT_TYPE"));
                countColumnControl++;
                jTable5.addString(countRowControl, countColumnControl, rset.getString("EVENT_TITLE"));
                countColumnControl++;
                jTable5.addString(countRowControl, countColumnControl, rset.getString("EVENT_DES"));
                countColumnControl++;

                countColumnControl = 0;
                countRowControl++;
            }

            //------------------------------------------------------------------------------------------------------------------

            countRow = 0;
            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday6+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");

            while (rset.next()){
                countRow++;
            }

            ResultSetMetaData metadata6 = rset.getMetaData();
            //countColumn2 = metadata.getColumnCount();

            jTable6.setDataSize(countRow, 4);
            jTable6.setColumnNameSize();
            //end

            DatabaseMetaData meta6 = userMainPage.con.getMetaData();

            rset = meta6.getColumns(null, null, "EVENT", null);

            // end

            jTable6.setColumnName(0, "Time");
            jTable6.setColumnName(1, "Type");
            jTable6.setColumnName(2, "Event");
            jTable6.setColumnName(3, "Description");

            countRowControl = 0;
            countColumnControl = 0;

            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday6+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");
            while(rset.next()){
                jTable6.addString(countRowControl, countColumnControl, rset.getString("EVENT_TIME"));
                countColumnControl++;
                jTable6.addString(countRowControl, countColumnControl, rset.getString("EVENT_TYPE"));
                countColumnControl++;
                jTable6.addString(countRowControl, countColumnControl, rset.getString("EVENT_TITLE"));
                countColumnControl++;
                jTable6.addString(countRowControl, countColumnControl, rset.getString("EVENT_DES"));
                countColumnControl++;

                countColumnControl = 0;
                countRowControl++;
            }

            //------------------------------------------------------------------------------------------------------------------

            countRow = 0;
            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday7+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");

            while (rset.next()){
                countRow++;
            }

            ResultSetMetaData metadata7 = rset.getMetaData();
            //countColumn2 = metadata.getColumnCount();

            jTable7.setDataSize(countRow, 4);
            jTable7.setColumnNameSize();
            //end

            DatabaseMetaData meta7 = userMainPage.con.getMetaData();

            rset = meta7.getColumns(null, null, "EVENT", null);

            // end

            jTable7.setColumnName(0, "Time");
            jTable7.setColumnName(1, "Type");
            jTable7.setColumnName(2, "Event");
            jTable7.setColumnName(3, "Description");

            countRowControl = 0;
            countColumnControl = 0;

            rset = userMainPage.stmt.executeQuery("Select EVENT_TIME,EVENT_TYPE,EVENT_TITLE,EVENT_DES From EVENT Where EVENT_DATE='"+fday7+"' AND USER_CODE="+userMainPage.userCode+"  ORDER BY EVENT_TIME");
            while(rset.next()){
                jTable7.addString(countRowControl, countColumnControl, rset.getString("EVENT_TIME"));
                countColumnControl++;
                jTable7.addString(countRowControl, countColumnControl, rset.getString("EVENT_TYPE"));
                countColumnControl++;
                jTable7.addString(countRowControl, countColumnControl, rset.getString("EVENT_TITLE"));
                countColumnControl++;
                jTable7.addString(countRowControl, countColumnControl, rset.getString("EVENT_DES"));
                countColumnControl++;

                countColumnControl = 0;
                countRowControl++;
            }
            



        }

        catch (Exception e){
            System.out.println("error");
        }

        Table1.setModel(jTable1);
        Table1.show();
        Table2.setModel(jTable2);
        Table2.show();
        Table3.setModel(jTable3);
        Table3.show();
        Table4.setModel(jTable4);
        Table4.show();
        Table5.setModel(jTable5);
        Table5.show();
        Table6.setModel(jTable6);
        Table6.show();
        Table7.setModel(jTable7);
        Table7.show();
        
        for(int i = 0; i < 3; i++){
                TableColumn column = Table1.getColumnModel().getColumn(i);
                if (i==0) {
                    column.setPreferredWidth(25);
                    column.setCellRenderer( centerRenderer );
                }
                if (i==1) {
                    column.setPreferredWidth(40);
                    column.setCellRenderer( centerRenderer );
                }
                if (i==2) column.setPreferredWidth(50);
                TableColumn column1 = Table2.getColumnModel().getColumn(i);
                if (i==0) {
                    column1.setPreferredWidth(25);
                    column1.setCellRenderer( centerRenderer );
                }
                if (i==1) {
                    column1.setPreferredWidth(40);
                    column1.setCellRenderer( centerRenderer );
                }
                if (i==2) column1.setPreferredWidth(50);
                TableColumn column2 = Table3.getColumnModel().getColumn(i);
                if (i==0) {
                    column2.setPreferredWidth(25);
                    column2.setCellRenderer( centerRenderer );
                }
                if (i==1) {
                    column2.setPreferredWidth(40);
                    column2.setCellRenderer( centerRenderer );
                }
                if (i==2) column2.setPreferredWidth(50);
                TableColumn column3 = Table4.getColumnModel().getColumn(i);
                if (i==0) {
                    column3.setPreferredWidth(25);
                    column3.setCellRenderer( centerRenderer );
                }
                if (i==1) {
                    column3.setPreferredWidth(40);
                    column3.setCellRenderer( centerRenderer );
                }
                if (i==2) column3.setPreferredWidth(50);
                TableColumn column4 = Table5.getColumnModel().getColumn(i);
                if (i==0) {
                    column4.setPreferredWidth(25);
                    column4.setCellRenderer( centerRenderer );
                }
                if (i==1) {
                    column4.setPreferredWidth(40);
                    column4.setCellRenderer( centerRenderer );
                }
                if (i==2) column4.setPreferredWidth(50);
                TableColumn column5 = Table6.getColumnModel().getColumn(i);
                if (i==0) {
                    column5.setPreferredWidth(25);
                    column5.setCellRenderer( centerRenderer );
                }
                if (i==1) {
                    column5.setPreferredWidth(40);
                    column5.setCellRenderer( centerRenderer );
                }
                if (i==2) column5.setPreferredWidth(50);
                TableColumn column6 = Table7.getColumnModel().getColumn(i);
                if (i==0) {
                    column6.setPreferredWidth(25);
                    column6.setCellRenderer( centerRenderer );
                }
                if (i==1) {
                    column6.setPreferredWidth(40);
                    column6.setCellRenderer( centerRenderer );
                }
                if (i==2) column6.setPreferredWidth(50);
        }
        
    }

   
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new checkUpcomingEvent().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JTable Table1;
    private javax.swing.JTable Table2;
    private javax.swing.JTable Table3;
    private javax.swing.JTable Table4;
    private javax.swing.JTable Table5;
    private javax.swing.JTable Table6;
    private javax.swing.JTable Table7;
    private javax.swing.JButton backButton;
    private javax.swing.JLabel background;
    private javax.swing.JLabel day1;
    private javax.swing.JLabel day2;
    private javax.swing.JLabel day3;
    private javax.swing.JLabel day4;
    private javax.swing.JLabel day5;
    private javax.swing.JLabel day6;
    private javax.swing.JLabel day7;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JButton listAllBtn;
    // End of variables declaration

}


